]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
dbusServices/extensions: Improve error message formatting
authorPhilip Chimento <philip.chimento@gmail.com>
Sat, 2 Dec 2023 18:27:20 +0000 (10:27 -0800)
committerFlorian Müllner <fmuellner@gnome.org>
Thu, 4 Jan 2024 18:59:33 +0000 (18:59 +0000)
See https://gitlab.gnome.org/GNOME/gjs/-/issues/584 for a user report.

This uses the new formatter added in the previous commit to format
errors in the extension preferences loader.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3041>

js/dbusServices/extensions/extensionPrefsDialog.js
js/dbusServices/org.gnome.Shell.Extensions.src.gresource.xml

index 50b2e92f597fe826649692dc0cee815f786f9206..334640d5eff71f758c020e72b4063282be6b7d73 100644 (file)
@@ -7,6 +7,8 @@ import GLib from 'gi://GLib';
 import GObject from 'gi://GObject';
 import Gtk from 'gi://Gtk?version=4.0';
 
+import {formatError} from './misc/errorUtils.js';
+
 export const ExtensionPrefsDialog = GObject.registerClass({
     GTypeName: 'ExtensionPrefsDialog',
     Signals: {
@@ -120,21 +122,14 @@ const ExtensionPrefsErrorPage = GObject.registerClass({
         this._revealer.connect('notify::child-revealed',
             () => this._syncExpandedStyle());
 
-        this._errorView.buffer.text = `${error}\n\nStack trace:\n`;
-        // Indent stack trace.
-        this._errorView.buffer.text +=
-            error.stack.split('\n').map(line => `  ${line}`).join('\n');
+        const formattedError = formatError(error);
+        this._errorView.buffer.text = formattedError;
 
         // markdown for pasting in gitlab issues
         let lines = [
             `The settings of extension ${this._uuid} had an error:`,
             '```',
-            `${error}`,
-            '```',
-            '',
-            'Stack trace:',
-            '```',
-            error.stack.replace(/\n$/, ''), // stack without trailing newline
+            formattedError.replace(/\n$/, ''),  // remove trailing newline
             '```',
             '',
         ];
index 55be1d199b2da6c2a20a72d8ea2d2a96741549c5..5db7b115f6cf752d323c1fc3642324b6e636cdc0 100644 (file)
@@ -10,6 +10,7 @@
     <file>extensions/prefs.js</file>
 
     <file>misc/config.js</file>
+    <file>misc/errorUtils.js</file>
     <file>misc/extensionUtils.js</file>
     <file>misc/dbusUtils.js</file>
     <file>misc/params.js</file>